package com.gome.ocean.dao.model.cango;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import com.google.common.collect.Sets;

/**
 * 转换对象
 * 
 * @author haqiaolong
 */
public class CangoInstances {

    private Long id;// 主键id

    /**
     * 实例名称 缓存KEY
     */
    private String name;

    /**
     * 源数据库信息
     */
    private String sourceHost;
    private int    sourcePort;
    private String sourceDBname;
    private String sourceType;
    private String sourceUserName;
    private String sourcePassword;
    private String sourceJDBCUrl; // 源jdbcUrl

    /**
     * 目标数据库信息
     */
    private String targetHost;
    private int    targetPort;
    private String targetDBname;
    private String targetType;
    private String targetUserName;
    private String targetPassword;
    private String targetJDBCUrl; // 目标JDBCUrl

    /**
     * 相关配置
     */
    private Set<String> tableNames = new HashSet<String>();
    private Integer     slaveId;
    private String      blackTables;
    private int         state;
    private Date        createTime;
    private Date        updateTime;
    private String      tables;
    private String      projectName;
    /**
     * rocketMq配置
     */
    private String      topicname;
    private String      namesrvaddr;
    private Integer     serialize;                         // 0为false 1:true
    private String      encode;
    private Integer     moveMode;                          // 愚公迁移模式
    private Integer     rocketMqVal;                       // 是否roceketmq
    private String      targetTableName;                   // 目标表

    public String getTargetTableName() {
        return targetTableName;
    }

    public void setTargetTableName(String targetTableName) {
        this.targetTableName = targetTableName;
    }

    public Integer getRocketMqVal() {
        return rocketMqVal;
    }

    public void setRocketMqVal(Integer rocketMqVal) {
        this.rocketMqVal = rocketMqVal;
    }

    public Integer getMoveMode() {
        return moveMode;
    }

    public void setMoveMode(Integer moveMode) {
        this.moveMode = moveMode;
    }

    public String getProjectName() {
        return projectName;
    }

    public void setProjectName(String projectName) {
        this.projectName = projectName;
    }

    public String getBlackTables() {
        return blackTables;
    }

    public void setBlackTables(String blackTables) {
        this.blackTables = blackTables;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public CangoInstances(){
    }

    public String getName() {
        return name;
    }

    public String getTables() {
        return tables;
    }

    public void setTables(String tables) {
        String[] str = tables.split(",");
        for (int i = 0; i < str.length; i++) {
            this.tableNames.add(str[i]);
        }
        this.tables = tables;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getSourceUserName() {
        return sourceUserName;
    }

    public void setSourceUserName(String sourceUserName) {
        this.sourceUserName = sourceUserName;
    }

    public String getTargetUserName() {
        return targetUserName;
    }

    public void setTargetUserName(String targetUserName) {
        this.targetUserName = targetUserName;
    }

    public String getSourcePassword() {
        return sourcePassword;
    }

    public void setSourcePassword(String sourcePassword) {
        this.sourcePassword = sourcePassword;
    }

    public String getTargetPassword() {
        return targetPassword;
    }

    public void setTargetPassword(String targetPassword) {
        this.targetPassword = targetPassword;
    }

    public Set<String> getTableNames() {
        Set<String> table = Sets.newHashSet();
        if (tableNames != null && tableNames.size() > 0) {
            for (String tab : tableNames) {
                table.add(this.sourceDBname + "." + tab);
            }
        }
        return table;
    }

    public void setTableNames(Set<String> tableNames) {
        this.tableNames = tableNames;
    }

    public String getTargetType() {
        return targetType;
    }

    public void setTargetType(String targetType) {
        this.targetType = targetType;
    }

    public String getSourceType() {
        return sourceType;
    }

    public void setSourceType(String sourceType) {
        this.sourceType = sourceType;
    }

    public Integer getSlaveId() {
        return slaveId;
    }

    public void setSlaveId(Integer slaveId) {
        this.slaveId = slaveId;
    }

    public String getSourceHost() {
        return sourceHost;
    }

    public void setSourceHost(String sourceHost) {
        this.sourceHost = sourceHost;
    }

    public int getSourcePort() {
        return sourcePort;
    }

    public void setSourcePort(int sourcePort) {
        this.sourcePort = sourcePort;
    }

    public String getSourceDBname() {
        return sourceDBname;
    }

    public void setSourceDBname(String sourceDBname) {
        this.sourceDBname = sourceDBname;
    }

    public String getTargetHost() {
        return targetHost;
    }

    public void setTargetHost(String targetHost) {
        this.targetHost = targetHost;
    }

    public int getTargetPort() {
        return targetPort;
    }

    public void setTargetPort(int targetPort) {
        this.targetPort = targetPort;
    }

    public String getTargetDBname() {
        return targetDBname;
    }

    public void setTargetDBname(String targetDBname) {
        this.targetDBname = targetDBname;
    }

    public int getState() {
        return state;
    }

    public void setState(int state) {
        this.state = state;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    public String getTopicname() {
        return topicname;
    }

    public void setTopicname(String topicname) {
        this.topicname = topicname;
    }

    public String getNamesrvaddr() {
        return namesrvaddr;
    }

    public void setNamesrvaddr(String namesrvaddr) {
        this.namesrvaddr = namesrvaddr;
    }

    public Integer getSerialize() {
        return serialize;
    }

    public void setSerialize(Integer serialize) {
        this.serialize = serialize;
    }

    public String getEncode() {
        return encode;
    }

    public void setEncode(String encode) {
        this.encode = encode;
    }

    public String getSourceJDBCUrl() {
        return sourceJDBCUrl;
    }

    public void setSourceJDBCUrl(String sourceJDBCUrl) {
        this.sourceJDBCUrl = sourceJDBCUrl;
    }

    public String getTargetJDBCUrl() {
        return targetJDBCUrl;
    }

    public void setTargetJDBCUrl(String targetJDBCUrl) {
        this.targetJDBCUrl = targetJDBCUrl;
    }

}
